package com.academic_system.mapper;

import com.academic_system.model.PartyActivityConditions;
import org.springframework.stereotype.Repository;

/**
 * @author 20155880 房雁颖
 * @description 党支部活动动态查询
 * @project_name
 * @package
 * @create 2018-11-17 20:48
 **/
@Repository
public class PartyActivitySqlProvider {
    public String queryPartyActivityByConditions(PartyActivityConditions partyActivityConditions) {
        StringBuilder sql = new StringBuilder("select * from party_activity  where party_organization_num=#{partyOrganizationNum}");
        if (partyActivityConditions.getPartyActivityName()!=null){
            sql.append(" and party_activity_name like CONCAT(CONCAT('%',#{partyActivityName}),'%')");
        }
        if ((partyActivityConditions.getPartyActivityStartTime()!=null)){
            sql.append(" and party_activity_time>#{partyActivityStartTime}");
        }
        if (partyActivityConditions.getPartyActivityEndTime()!=null){
            sql.append(" and party_activity_time<#{partyActivityEndTime}");
        }
        System.out.println(sql.toString());
        return sql.toString();
    }

    public String queryPartyActivityByConditionsByCache(PartyActivityConditions partyActivityConditions) {
        StringBuilder sql = new StringBuilder("select * from party_activity  where party_organization_num=#{partyOrganizationNum} ");
        if (partyActivityConditions.getPartyActivityName()!=null){
            sql.append(" and party_activity_name like CONCAT(CONCAT('%',#{partyActivityName}),'%')");
        }
        if ((partyActivityConditions.getPartyActivityStartTime()!=null)){
            sql.append(" and party_activity_time>#{partyActivityStartTime}");
        }
        if (partyActivityConditions.getPartyActivityEndTime()!=null){
            sql.append(" and party_activity_time<#{partyActivityEndTime}");
        }
        System.out.println(sql.toString());
        return sql.toString();
    }

//    public String queryPartyActivityTempByConditions(PartyActivityConditions partyActivityConditions) {
//        StringBuilder sql = new StringBuilder("select * from party_activity_temp  where party_organization_num=#{partyOrganizationNum} ");
//        if (partyActivityConditions.getPartyActivityName()!=null){
//            sql.append(" and party_activity_name like CONCAT(CONCAT('%',#{partyActivityName}),'%')");
//        }
//        if ((partyActivityConditions.getPartyActivityStartTime()!=null)){
//            sql.append(" and party_activity_time>#{partyActivityStartTime}");
//        }
//        if (partyActivityConditions.getPartyActivityEndTime()!=null){
//            sql.append(" and party_activity_time<#{partyActivityEndTime}");
//        }
//        System.out.println(sql.toString());
//        return sql.toString();
//    }
}
